
#ifndef _BSP_MISC_H_
#define _BSP_MISC_H_

#include "main.h"



#define     LED_PIN LL_GPIO_PIN_15
#define     LED_GPIO_PORT GPIOA
#define     LED_GPIO_CLK_ENABLE()   LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA)

int bsp_led_init(void);
void bsp_led_toggle(void);
void bsp_led_write(uint8_t sta);


#define     BSP_TIM_NBR             TIM6
#define     BSP_TIM_CLK_ENABLE()    LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM6)
#define     BSP_TIM_IRQn            TIM6_IRQn
#define     BSP_TIMER_ISR           TIM6_IRQHandler

typedef void (*bsp_ticktim_cbf_t)(void);
int bsp_ticktim_init(void);
void bsp_ticktim_cbf_regist(bsp_ticktim_cbf_t fun);


#define     BSP_KEY1_PIN            LL_GPIO_PIN_15
#define     BSP_KEY1_PORT           GPIOC
#define     BSP_KEY1_CLK_ENABLE()   LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC)

#define     BSP_KEY2_PIN            LL_GPIO_PIN_14
#define     BSP_KEY2_PORT           GPIOC
#define     BSP_KEY2_CLK_ENABLE()   LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC)

#define     BSP_KEY3_PIN            LL_GPIO_PIN_13
#define     BSP_KEY3_PORT           GPIOC
#define     BSP_KEY3_CLK_ENABLE()   LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC)

typedef enum {
    BSP_KEY1,
    BSP_KEY2,
    BSP_KEY3,
    BSP_KEY_SUM
} KEYID_T;


void bsp_key_init(void);
uint8_t bsp_read_key_sta(uint8_t _key);

#endif
